package com.efuture.androidmvpdemo.ui.main

import com.efuture.androidmvpdemo.ui.base.BasePresenter
import com.efuture.netrequestdemo.bean.Project
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel

/**

 *@description:TODO
 * @author: zhaoshanshan
 * @date: 2022/3/26 6:58 下午

 */
class MainPresenter (var mainView:MainView?,val mainInteractor: MainInteractor) :MainInteractor.MainListener,BasePresenter{


    //获取主页数据
    fun getHomepageData(mainScope: CoroutineScope) {

        mainInteractor.loadData(mainScope,this)

    }

    override fun loadDataSuccess(projectData: Project) {

        mainView?.loadDataSuccess(projectData)

    }

    override fun loadDataFail(reason: String) {
        mainView?.loadDataFail(reason)
    }

    override fun onDestroyView(mainScope: CoroutineScope) {
        mainView = null
        mainScope?.cancel()
    }

}